/*
 * @Author: error: git config user.name && git config user.email & please set dead value or install git
 * @Date: 2022-08-16 13:30:35
 * @LastEditors: error: git config user.name && git config user.email & please set dead value or install git
 * @LastEditTime: 2022-08-24 11:25:42
 * @FilePath: \四阶段项目\src\service\workOrderService.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import axios from "../utils/axios";
import api from '../api'

//工单列表 所有工单
export function getAllDataList(currentPage,pageSize){
    return new Promise((reslove,reject)=>{
        axios({
            url:api.userorderApi.GETWORKORDER_DATA,
          method:'get',
          params:{
            currentPage,
            pageSize
          }
        }).then((res)=>{
            reslove(res.data)
            
        }).catch((err)=>{
             console.log(err);
        })
    })}
//工单列表  工单列表已完成按钮，工单列表处理中按钮，工单列表未处理按钮
export function getDataList(currentPage,pageSize,processing_status){
  return new Promise((reslove,reject)=>{
    axios({
      url:api.userorderApi.GETWORKORDERCOMPLETED_DATA,
      method:'get',
      params:{
        currentPage,pageSize,processing_status
      }
    }).then((res)=>{
      console.log(res.data,'getDataList');
    })
  })
}
//点击客户名称 处理状态  修改按钮  工作记录 发起请求
export function getCheckWorkOrderList(work_order_id){
      return new Promise((reslove,reject)=>{
          axios({
              url:api.userorderApi.CHECKWORKORDER_DATA,
            method:'get',
            params:{
              work_order_id
            }
          }).then((res)=>{
              reslove(res.data)
              console.log(res.data,'getCheckWorkOrderList');
          }).catch((err)=>{
               console.log(err);
          })
      })}

      //处理状态改变 点击模态框确定发起请求
      export function disposeState(work_order_id,processing_status){
        return new Promise((reslove,reject)=>{
          axios({
            url:api.userorderApi.DISPOSESTATE_REQUESET,
            method:'post',
            data:{
              work_order_id,processing_status
            }
          }).then((res)=>{
              console.log(res.data,'disposeState');
              reslove(res.data)
          }).catch((err)=>{
            console.log(err);
          })
        })
      }
      
// 点击工作记录  发起请求
export function getRecordworkOrderList(work_order_id){
         return new Promise((reslove,reject)=>{
            axios({
                url:api.userorderApi.RECORDWORKORDER_DATA,
              method:'get',
              params:{
                work_order_id
              }
            }).then((res)=>{
                reslove(res.data)
                console.log(res.data,'getRecordworkOrderList');
            }).catch((err)=>{
                 console.log(err);
            })
        })}

        //点击表格修改按钮里的保存按钮 发起请求

export function updateWorkOrderList(work_order_id,work_order_type,customer_name,contact_name,start_time,end_time,traffic_mode,travel_contact,job_describe,assigned_personnel,user_name){
  return new Promise((reslove,reject)=>{
    axios({
      url:api.userorderApi.UPDATEWORKORDER_DATA,
      method:'POST',
      data:{
        work_order_id,work_order_type,customer_name,contact_name,start_time,end_time,traffic_mode,travel_contact,job_describe,assigned_personnel,user_name
      }
    }).then((res)=>{
      reslove(res.data)
      console.log(res.data,'修改保存发起的');
    }).catch((err)=>{
console.log(err);
    })
  })
}

//点击表格删除按钮发起请求
export function deleteWorkOrderList(work_order_id){
  return new Promise((reslove,reject)=>{
    axios({
      url:api.userorderApi.DELETEWORKORDER_DATA,
      method:'post',
      data:work_order_id
    }).then((res)=>{
      console.log(res,'删除发起的');
      reslove(res.data)
    }).catch((err)=>{
console.log(err);
    })
  })
}

//我发起的 按钮发起请求
export function Mystarted(currentPage,pageSize,user_name){
  return new Promise((reslove,reject)=>{
    axios({
      url:api.userorderApi.GETSTARTWORKORDER_DATA,
      method:'get',
      params:{
        currentPage,
        pageSize,
        user_name
      }
    }).then((res)=>{
      console.log(res,'我发起的 按钮请求');
      reslove(res.data)
    }).catch((err)=>{
       console.log(err);
    })
  })
}
//我参与的  按钮发起请求
export function Myjoin(currentPage,pageSize,assigned_personnel){
  return new Promise((resolve,reject)=>{
    axios({
      url:api.userorderApi.GETMYJOINWORKORDER_DATA,
      method:'get',
      params:{
        currentPage,
        pageSize,
        assigned_personnel
      }
    }).then((res)=>{
       console.log(res,'我参与的');
       resolve(res.data)
    }).catch((err)=>{
      console.log(err);
    })
  })
}
//搜索按钮 发起请求
export function searchBtn(currentPage,pageSize,condition){
  return new Promise((reslove,reject)=>{
    axios({
      url:api.userorderApi.SEARCHWORKORDER_DATA,
      method:'get',
      params:{
        currentPage,pageSize,condition
      }
    }).then((res)=>{
     console.log(res,'搜索按钮');
     reslove(res.data)
    }).catch((err)=>{
      console.log(err);
    })
  })
}
//新增按钮 发起请求
export function addBtn(currentPage,pageSize){
  return new Promise((reslove,reject)=>{
    axios({
      url:api.userorderApi.ADDWORKORDER_DATA,
      method:'get',
      params:{
        currentPage,pageSize,
      }
    }).then((res)=>{
     console.log(res,'新增按钮');
     reslove(res.data)
    }).catch((err)=>{
      console.log(err);
    })
  })
}
    // export function onPageChange(currentPage,pageSize){
    //    console.log('页码改变发起请求重新渲染');
    // }